
Character = PermanentGameelement:new()

Character.str = 0
Character.agi = 0
Character.int = 0
Character.dex = 0

Character.nativeStr = 0
Character.nativeAgi = 0
Character.nativeInt = 0
Character.nativeDex = 0

Character.skp = 0

Character.level = 0
Character.exp = 0
Character.direction = "south"

function Character:calculateAtributes( ) -- calculates the atributes of the Char instance, if available includes the Equipment

	self.str = self.nativeStr
	self.agi = self.nativeAgi
	self.int = self.nativeInt
	self.dex = self.nativeDex
	 
	if self.Equipment then
	local bonusTable = self:readEquipment()
		for k,v in pairs( self.inventory) do
			self[k] = self[k] + v
		end
	end
end

function Character:levelUp( ) -- the character gests an level up
	self.level = self.level + 1
	self.hp = self.hpMax
	self.mana = self.manaMax
	self.skp = self.skp + 5
	t:newoht("Level up!!  "..self.level)
end

function Character:walk() -- 
	if self.dir == 'north' then self.y = self.y - self.movementSpeed
	elseif self.dir == 'east' then self.x = self.x + self.movementSpeed
	elseif self.dir == 'south' then self.y = self.y + self.movementSpeed
	elseif self.dir == 'west' then 	self.x = self.x - self.movementSpeed
	elseif self.dir == 'northeast' then 	self.x = self.x + self.movementSpeed
		self.y = self.y- self.movementSpeed
	elseif self.dir == 'southeast' then 	self.x = self.x + self.movementSpeed
		self.y = self.y+ self.movementSpeed
	elseif self.dir == 'southwest' then 	self.x = self.x - self.movementSpeed
		self.y = self.y+ self.movementSpeed
	elseif self.dir == 'northwest' then 	self.x = self.x - self.movementSpeed
		self.y = self.y- self.movementSpeed
	end
-- avoids that an enemy can leave the screen
	if self.x < 0 then self.x = 0 end
	if self.x + self.wid > SCREEN_WIDTH then self.x = SCREEN_WIDTH - self.wid end
	if self.y < 0 then self.y = 0 end
	if self.y + self.hig > SCREEN_HEIGHT then self.y = SCREEN_HEIGHT - self.hig end
end

dofile('itemsystem.lua')

dofile('enemy.lua')
dofile('hero.lua')
